#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 1e5 + 10;

void solve()
{
     map<char,int> mp1;
     map<char,int> mp2;
     int cnt1[N];
     int cnt2[N];
     string a,b;
     cin >> a >> b;
     if((a == b) || (a.size() == 1 && b.size() == 1))
     {
        cout << "YES" << endl;
        return ;
     }
     for(int i = 0; i < a.size(); i++)
     {
          mp1[a[i]] ++ ;
          mp2[b[i]] ++;
     }
     int ans = 0;
     for(int i = 'a'; i <= 'z'; i++)
     {
        if(mp1[i] != mp2[i]) ans += abs(mp1[i] - mp2[i]);
     }
     if(ans > 2) cout << "NO" << endl;
     else cout << "YES" << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t ;
    cin >> t;
    while(t -- )
  {
    solve();
  }
    return 0;
}